#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, m;
int a[N];

int solve(int a[], int n, int m) {
	sort(a, a + n);
	int temp = m - a[0];
	int l = 0, r = n - 1;
	while (l < r) {
		int mid = l + r >> 1;
		if (a[mid] >= temp) {
			r = mid;
		} else {
			l = mid + 1;
		}
	}
	int sum = 0;
	int i = 0, j = l;
	while (i < n && j >= 0) {
		if (a[i] + a[j] == m) {
			i++;
			--j;
			sum++;
		} else if (a[i] + a[j] < m) {
			break;
		} else if (a[i] + a[j] > m) {
			while (a[i] + a[j] > m) {
				--j;
			}
		}
	}
	return sum / 2;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	cout << solve(a, n, m) << endl;
	return 0;
}